<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends CommonAction {

    public function index(){
		if(isset($_SESSION['username'])){
			$this->assign('title', '后台首页');
			$this->display();
		}else{
			$this->display('Public:login');
		}

    }
	public function systeminfo(){
		$this->display();
	}

	public function systemset(){

		$siteinfo = $_POST;
		$file = $siteinfo['filename'];
		if($file=="siteconfig.inc.php"){
			unset($siteinfo['filename']);
		unset($siteinfo['__hash__']);
			if($siteinfo['sitename']==''){$siteinfo['sitename']='Emit_site';};
			if($siteinfo['metakey']==''){$siteinfo['metakey']='Emit_site关键字';};
			if($siteinfo['metadesc']==''){$siteinfo['metadesc']='Emit_site详情';};
			if($siteinfo['pagenum']==''){$siteinfo['pagenum']=10;};
			if($siteinfo['email']==''){$siteinfo['email']='Xnfy520@qq.com';};
			if($siteinfo['contact']==''){$siteinfo['contact']='Emit';};
			if($siteinfo['phone']==''){$siteinfo['phone']=110;};
			if($siteinfo['address']==''){$siteinfo['address']='Emit';};
			if($siteinfo['offline']==''){$siteinfo['offline']=0;};
			if($siteinfo['offlinemessage']==''){$siteinfo['offlinemessage']='暂时关闭网站';};

			$content = "<?php \n\n\treturn array(\n";
			foreach($siteinfo as $key=>$value){
				$key = strtoupper($key);
				if(!strtolower($value) || is_numeric($value)){
					$content.="\t'$key'=>$value,\n";
				}else{
					$content.="\t'$key'=>'$value',\n";
				}
			}
			$content.="\n);";
			$f = chmod($file, 0755);
			$put = file_put_contents($file, $content);
			if($put){
				$this->success('修改系统配置文件成功');

			}else{
				$this->error('修改系统配置文件失败');
			}
		}else{
			$this->error('不存在此配置文件');
		}
	}


}